#! /bin/sh
## see arch wiki: https://wiki.archlinux.org/title/Bspwm 4.4
## for fix java app: Gray window, applications not resizing with WM, menus immediately closing
#wmname LG3D
# set wmname to LG3D will cause other app 
export _JAVA_AWT_WM_NONREPARENTING=1
export AWT_TOOLKIT=MToolkit

#source /home/bin/0bin/config/fcitx5.env

#xrdb .Xresources &
#export SPACEMACSDIR=~/.emacsren.d

#picom -b -c --config ~/.config/bspwm/picom.conf &
dunst -config ~/.config/bspwm/dunstrc &
xautolock -time 3 -locker "~/.local/bin/lock.sh" &

hn=$(hostname)
notify-send -t 15000 "start" $hn "desktop"
case $hn in
  sren-home-pc)
    kmonad ~/.config/bspwm/kmonad/kmonad.bloody.kbd &
    kmonad ~/.config/bspwm/kmonad/kmonad.bloody2.kbd &
    kmonad ~/.config/bspwm/kmonad/kmonad.bloody.media.kbd &
    polybar -r -c ~/.config/bspwm/polybar.conf twoBarHomeMain &
    polybar -r -c ~/.config/bspwm/polybar.conf twoBarHomeLeft &
    $(sleep 3 && landrop) &
    bspc monitor "DP-1" -d 1 2 3 4 5
    bspc monitor "DVI-D-1" -d q w e r t
    ;;
  renshuo-work)
    notify-send -t 15 "start work desktop"
    picom -b -c --backend glx &
    eww daemon
    eww open workMain
    eww open workLeft
    # polybar -r -c /home/bin/0bin/config/bspwm/polybar.conf workMain >> /home/bin/0bin/config/bspwm/polybar-workMain.log &
    # polybar -r -c /home/bin/0bin/config/bspwm/polybar.conf workLeft >> /home/bin/0bin/config/bspwm/polybar-workLeft.log &
    bspc monitor "VGA-0" -d 1 2 3 4 5
    bspc monitor "DVI-0" -d q w e r t
    systemctl --user start kmonad-bloody
    systemctl --user start kmonad-bloody2
    ;;
  sren-laptop)
      #polybar -r -c /home/bin/0bin/config/bspwm/polybar.conf laptop >> /home/bin/0bin/config/bspwm/polybar-laptop.log &
      picom -b -c --backend glx &
      eww daemon
      eww open main
      bspc monitor -d 1 2 3 4 q w e r
      #systemctl --user start kmonad-laptop
   ;;
  *)
    kmonad ~/.config/bspwm/kmonad/kmonad.$(hostname).kbd &
    polybar -r -c ~/.config/bspwm/polybar.conf laptop &
    notify-send -t 15 "start unknown desktop"
  ;;
esac

#stalonetray &
#light-locker &
#udiskie &
fcitx5 &
nutstore &
nm-applet --indicator &
blueman-applet &
pasystray &
#kdeconnect &
#landrop &
localsend --hidden &
clash-verge &
optimus-manager-qt &
thunderbird &

#flameshot & ## 截屏
variety & ## 壁纸
tdrop -ma -h -24 -w -4 -y 24 'alacritty -e tmux' &
tdrop -ma -h -24 -w -4 -y 24 "emacs" &
tdrop -ma -h -24 -w -2 -y 24 "dolphin" &
$(sleep 4 && tdrop hide_all)

$(sleep 10 && fixkdeopen.sh)

######################
##### bsp theme config #####

#bspc config top_padding          24

bspc config pointer_modifier     mod4

bspc config window_gap           1

bspc config border_width         2
bspc config normal_border_color "#ffaa33"
bspc config focused_border_color "#33aaff"
bspc config active_border_color "#33ffaa"

bspc config split_ratio          0.52
bspc config borderless_monocle   true
bspc config gapless_monocle      true



bspc config focus_stealing_enabled false
bspc config focus_follows_pointer true
bspc config focus_stealing_enabled false
bspc config pointer_follows_focus true
bspc config follow_focused_monitor true
bspc config manage_placement true
bspc config raise_on_focus true
bspc config top_padding 0
bspc config bottom_padding 0
bspc config left_padding 0
bspc config right_padding 0
bspc config window_gap 10
bspc config border_width 2
bspc config split_ratio 0.5
bspc config auto_padding false
bspc config gapless_monocle false
bspc config borderless_monocle false
bspc config preserve_quitters false
bspc config remove_unmanageable true
bspc config swap_monitors_on_cross false
bspc config follow_move true
bspc config pointer_modifier mod4
bspc config pointer_action1 move
bspc config pointer_action2 resize_side
bspc config pointer_action3 resize_corner
bspc config pointer_threshold 2
bspc config focus_follows_pointer true
bspc config floating_placement center


### rules ###
bspc rule -a Pavucontrol state=floating focus=on

bspc rule -a firefox desktop='q' follow=on
bspc rule -a Chromium desktop='w'

bspc rule -a mplayer2 state=floating
bspc rule -a mpv state=floating
bspc rule -a vlc state=floating

bspc rule -a Screenkey manage=off
#bspc rule -a Nutstore desktop='^8'
bspc rule -a stalonetray state=floating
bspc rule -a Nm-connection-editor state=floating
bspc rule -a blueman-services state=floating
bspc rule -a fcitx5-config-qt state=floating
bspc rule -a fcitx5-configtool state=floating
bspc rule -a flameshot state=floating
bspc rule -a Variety state=floating
bspc rule -a Blueman-manager state=floating
bspc rule -a matplotlib state=floating
bspc rule -a octave-gui state=floating
bspc rule -a Arandr state=floating
bspc rule -a Gimp desktop='^2' state=floating follow=on
bspc rule -a scrcpy state=floating
bspc rule -a kruler state=floating
bspc rule -a org.remmina.Remmina rectangle=1920x1055+0+25 state=floating border=off

bspc rule -a qq desktop='^4' state=floating follow=on
bspc rule -a netease-cloud-music desktop='4' state=floating follow=on

bspc rule -a 'Emacs':n='Helm.*' state=floating layer=above
